Skip to content

Conversation

@Zlendy
Copy link
Contributor

@Zlendy Zlendy commented Apr 17, 2025

Proposed change

Implements #1333

This widget shows the playback count from user-specified libraries in the last n days.
It uses the API endpoint http://jellystat.host.or.ip/stats/getViewsByLibraryType implemented in v1.1.16

Type of change

  • New service widget
  • Bug fix (non-breaking change which fixes an issue)
  • New feature or enhancement (non-breaking change which adds functionality)
  • Documentation only
  • Other (please explain)

Checklist:

  • If applicable, I have added corresponding documentation changes.
  • If applicable, I have reviewed the feature / enhancement and / or service widget guidelines.
  • I have checked that all code style checks pass using pre-commit hooks and linting checks.
  • If applicable, I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.

Jellystat

Usage

Generate an API key (http://jellystat.host.or.ip/settings)

image

Add this to services.yaml

- Dev:
    - Jellystat:
        href: http://jellystat.host.or.ip
        widget:
          type: jellystat
          url: http://jellystat.host.or.ip
          key: apikeyapikeyapikeyapikeyapikeyapikeyapikeyapikeyapikeyapikey
          fields: ["songs", "movies", "episodes", "other"]
          days: 30

Screenshots

image

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 17, 2025

I have not added any documentation yet because there's a few things I'd like to discuss with a maintainer first.

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 17, 2025

I have not used widget.fields and instead created a different YAML field widget.libraries, this is not a design decision but a limitation caused by this code:

visibleChildren = childrenArray?.filter((child) =>
fields.some((field) => {
let fullField = field;
if (!field.includes(".")) {
fullField = `${type}.${field}`;
}
let matches = fullField === child?.props?.label;
// check if the field is an 'alias'
if (matches) {
return true;
} else if (ALIASED_WIDGETS[type]) {
matches = fullField.replace(type, ALIASED_WIDGETS[type]) === child?.props?.label;
return matches;
}
// no match
return false;
}),
);

Is this acceptable or should I look into a way of using widget.fields like every other widget does?

Copy link
Collaborator

@shamoon shamoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about post.
And yes in general this needs to conform with other widgets, using fields etc. how you’ve coded this will break things like translations etc

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 17, 2025

how you’ve coded this will break things like translations

You can't translate the name of the library, that's part of the problem.

@shamoon
Copy link
Collaborator

shamoon commented Apr 17, 2025

how you’ve coded this will break things like translations

You can't translate the name of the library, that's part of the problem.

Ah, ok I kinda get what you mean here, the blocks are determined by the users install. I havent looked in detail yet but what other similar services do is to provide data that is more generic i.e. total up the # of videos / songs / whatever (I dont even know what jellystat is for yet, again havent looked)

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 17, 2025

how you’ve coded this will break things like translations

You can't translate the name of the library, that's part of the problem.

Ah, ok I kinda get what you mean here, the blocks are determined by the users install. I havent looked in detail yet but what other similar services do is to provide data that is more generic i.e. total up the # of videos / songs / whatever (I dont even know what jellystat is for yet, again havent looked)

Jellystat is Jellyfin's version of Tautulli. It provides statistics for many aspects of a Jellyfin server, one of which being user playback count.
I also thought of displaying data in a more generic way as you suggested here but ended up doing this instead to avoid making 2 API calls AND being forced to do this weird proxy/POST thing.

Nothing is stopping me from contributing first a new endpoint to Jellystat and use that here, but there's no guarantee that it will be merged (or when).

@shamoon
Copy link
Collaborator

shamoon commented Apr 17, 2025

Nothing is stopping me from contributing first a new endpoint to Jellystat and use that here, but there's no guarantee that it will be merged (or when).

Thats of course your call. I agree it could be nicer / easier to have some kind of overall 'stats' endpoint (many many projects do something like this) but yea I dont know how active / open that project is.

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 19, 2025

CyferShepard/Jellystat#378
With that PR merged, I can refactor this widget into something less janky.

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 20, 2025

Ok, refactoring done. This is now using an endpoint which is currently only on the unstable branch of Jellystat.

I suppose it would be a good idea to wait until it gets released in a stable version before this PR gets merged.

This new code is good enough imo. Should I start working on the documentation?


services.yml

- Dev:
    - Jellystat:
        href: http://jellystat.host.or.ip
        widget:
          type: jellystat
          url: http://jellystat.host.or.ip
          key: apikeyapikeyapikeyapikeyapikeyapikeyapikeyapikeyapikeyapikey
          fields: ["songs", "movies", "episodes", "other"]

New screenshots

Jellystat API Homepage
image image

@Zlendy Zlendy requested a review from shamoon April 20, 2025 17:54
@shamoon
Copy link
Collaborator

shamoon commented Apr 20, 2025

This is great and yea the code is much cleaner! I guess the only thing is as you said, we should at least wait until the API endpoint is released (and we'll be able to note the min required version in the docs). If it's going to be a few weeks might be better to close this and re-open when ready. Thanks again for the effort on both ends

@AdamWHY2K
Copy link
Contributor

just curious if this widget should also support streamystats or if that should be it's own fr?

@Zlendy
Copy link
Contributor Author

Zlendy commented Apr 21, 2025

That's a completely different service, unless it has a 100% identical API endpoint (which is extremely unlikely) it's not supported.

@AdamWHY2K
Copy link
Contributor

That's a completely different service, unless it has a 100% identical API endpoint (which is extremely unlikely) it's not supported.

just checked the API, doesn't look like it does. I'll make a separate fr for it :)

@shamoon
Copy link
Collaborator

shamoon commented Apr 21, 2025

@Zlendy just holler when they release your change, this can probably be reopened if it’s not too long from now. Thanks again.

@shamoon shamoon closed this Apr 21, 2025
@Zlendy
Copy link
Contributor Author

Zlendy commented May 1, 2025

@shamoon The required endpoint landed in the new jellystat release
https://github.com/CyferShepard/Jellystat/releases/tag/1.1.6

Please reopen this PR so that I can continue working on this feature

@shamoon shamoon reopened this May 1, 2025
@Zlendy Zlendy force-pushed the feat/jellystat branch 2 times, most recently from 6b7fa49 to a3c351d Compare May 2, 2025 08:14
@Zlendy
Copy link
Contributor Author

Zlendy commented May 2, 2025

I have rebased this branch to dev, added documentation and made a couple of small tweaks to the widget.
This is ready for review now.

@Zlendy Zlendy marked this pull request as ready for review May 2, 2025 08:19
@Zlendy Zlendy force-pushed the feat/jellystat branch 2 times, most recently from 380d782 to 1b4391c Compare May 2, 2025 11:44
Copy link
Collaborator

@shamoon shamoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, much cleaner. Tiny stuff here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be inserted alphabetical (ish) by widget name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to apply this suggestion, but honestly there are far too many widgets in the wrong order to be sure this is what you meant.

833db71b8770678c3c3efffe62286bef034c632e

@Zlendy Zlendy force-pushed the feat/jellystat branch from 833db71 to 5c1b480 Compare May 3, 2025 11:06
@shamoon shamoon enabled auto-merge (squash) May 3, 2025 15:26
Copy link
Collaborator

@shamoon shamoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks

Screenshot 2025-05-03 at 8 24 06 AM

@shamoon shamoon merged commit 7e87522 into gethomepage:dev May 3, 2025
5 checks passed
@pippo73
Copy link

pippo73 commented May 29, 2025

Sorry, but I'm running the version 1.2.0 but I cannot find this widget. Will it be released in a future version?

@shamoon
Copy link
Collaborator

shamoon commented May 29, 2025

Yes. Or you can run dev.

@pippo73
Copy link

pippo73 commented May 30, 2025

Yes. Or you can run dev.

Sorry what do you mean with "run dev" ? could you explain me pls :-)

@shamoon
Copy link
Collaborator

shamoon commented May 30, 2025

Change the docker image tag to dev

@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns. See our contributing guidelines for more details.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2025
@Zlendy Zlendy deleted the feat/jellystat branch June 30, 2025 19:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants